﻿using KillBill.Business.Entities;
using KillBill.Presentation.Modules.Administration.IView;

namespace KillBill.Presentation.Modules.Administration.Presenter
{
    public class PersonAddEditPresenter
    {
        public IPersonAddEdit View { get; set;}

        private readonly Person _person = new Person();

        public PersonAddEditPresenter(IPersonAddEdit iPersonAddEdit)
        {
            View = iPersonAddEdit;
        }

        public PersonAddEditPresenter(IPersonAddEdit iPersonAddEdit, Person person)
        {
            View = iPersonAddEdit;
            _person = person;
            MapView();
        }

        public Person MapPerson()
        {
            _person.PersonID = View.PersonID;
            _person.FirstName = View.FirstName;
            _person.LastName = View.LastName;
            _person.Email = View.Email;
            _person.Address = View.Address;
            _person.Phone = View.Phone;
            _person.ModifiedDate = View.ModifiedDate;
            return _person;
        }

        public IPersonAddEdit MapView()
        {
            View.PersonID = _person.PersonID;
            View.FirstName = _person.FirstName;
            View.LastName = _person.LastName;
            View.Email = _person.Email;
            View.Address = _person.Address;
            View.Phone = _person.Phone;
            View.ModifiedDate = _person.ModifiedDate;
            return View;
        }
    }
}
